package private

import (
	v1 "code.bydev.io/cht/customer/kyc-stub.git/pkg/bybit/kyc/admin/v1"
	"code.bydev.io/cht/customer/kyc_admin_service/internal/config"
	"code.bydev.io/cht/customer/kyc_admin_service/internal/utils/middleware"
	adminapiServer "code.bydev.io/cht/customer/kyc_admin_service/service/private/internal/server/adminapi"
	adminServer "code.bydev.io/cht/customer/kyc_admin_service/service/private/internal/server/kycadmininnerservice"
	"code.bydev.io/cht/customer/kyc_admin_service/service/private/internal/svc"
	"code.bydev.io/frameworks/byone/zrpc"
	"fmt"
	"git.bybit.com/svc/stub/pkg/pb/api/kycadmin"
	"google.golang.org/grpc"
)

func PrivateService(c config.Config) *zrpc.RpcServer {
	ctx := svc.NewServiceContext(c)
	s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
		kycadmin.RegisterKycAdminInnerServiceServer(grpcServer, adminServer.NewKycAdminInnerServiceServer(ctx))
		v1.RegisterAdminAPIServer(grpcServer, adminapiServer.NewAdminAPIServer(ctx))
	})
	s.AddUnaryInterceptors(
		// 打印请求前后req, resp, err
		middleware.LogServerInterceptor,
		middleware.MetricsServerInterceptor,
	)
	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
	return s
}
